//获取预制菜市场占有率的数据
import { PieSpiderChartList } from '@/services/PieSpiderChart';
import { useEffect, useState } from 'react';

type pieSpiderChartDataList = {
  type: string;
  value: number;
};

const usePieSpiderChart = (): pieSpiderChartDataList[] => {
  const [pieSpiderChart, setpieSpiderChart] = useState<
    pieSpiderChartDataList[]
  >([]);
  useEffect(() => {
    const fetchData = async () => {
      try {
        const res = await PieSpiderChartList();
        if (res.success) {
          console.log('pieSpiderChartList:', res.data.PieSpiderChart);
          setpieSpiderChart(res.data.PieSpiderChart);
        }
      } catch (error) {
        console.error('Error fetching pieSpiderChartList data:', error);
      }
    };

    fetchData();
  }, []);

  return pieSpiderChart;
};

export default usePieSpiderChart;
